#https://haokan.baidu.com/tab/gaoxiao
import requests
import json
import pprint
#https://haokan.baidu.com/videoui/api/videorec?tab=gaoxiao&act=pcFeed&pd=pc&num=20&shuaxin_id=1587522487725

base_url='https://haokan.baidu.com/videoui/api/videorec?tab=gaoxiao&act=pcFeed&pd=pc&num=20&shuaxin_id=1587522487725'
headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36'
    }
reponse=requests.get(base_url,headers=headers)
data=reponse.json()
data_list=data["data"]["response"]["videos"]
#pprint.pprint(data_list)
for data1 in data_list:
    #print(data1)
    vedio_title=data1["title"]+'.mp4'
    vedio_url=data1["play_url"]
    # print(vedio_title,vedio_url)
    vedio_data=requests.get(vedio_url,headers=headers).content
    with open("搞笑\\"+vedio_title,'wb') as f:
        print('正在下载'+vedio_title)
        f.write(vedio_data)
        print('下载完成.....')